package com.cwvs.cat;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;

import com.cwvs.cat.fragment.ActiveManageMyApplyFragment;
import com.cwvs.cat.fragment.ActiveManagerMyPublishFargment;

public class MyActiveManageActivity extends FragmentActivity {

	private ImageView img_select_publish,img_select_apply;
	private ProgressDialog myDialog = null;
	private ImageView header_leftImg;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_my_active_manage);
		initView();
	}

	private void initView(){
		img_select_publish=(ImageView) this.findViewById(R.id.img_select_publish);
		img_select_publish.setOnClickListener(myFriendOnClickListener);
		img_select_apply=(ImageView) this.findViewById(R.id.img_select_apply);
		img_select_apply.setOnClickListener(clubOnClickListener);
		header_leftImg = (ImageView) findViewById(R.id.header_leftImg);
		header_leftImg.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		img_select_publish.performClick();
	}


	private OnClickListener myFriendOnClickListener=new OnClickListener() {
		@Override
		public void onClick(View v) {
			clearSelection();
			img_select_publish.setImageResource(R.drawable.my_active_publish_blue);
			img_select_publish.setEnabled(false);
			FragmentManager fm=getSupportFragmentManager();
			FragmentTransaction ft=fm.beginTransaction();
			ActiveManagerMyPublishFargment publishFatherFragment=new ActiveManagerMyPublishFargment();
			ft.replace(R.id.linear_invate_contact, publishFatherFragment,MainActivity.TAG);
			ft.commit();


		}
	};

	private OnClickListener clubOnClickListener=new OnClickListener() {
		@Override
		public void onClick(View v) {
			clearSelection();
			img_select_apply.setImageResource(R.drawable.my_active_apply_blue);
			img_select_apply.setEnabled(false);
			FragmentManager fm=getSupportFragmentManager();
			FragmentTransaction ft=fm.beginTransaction();
			ActiveManageMyApplyFragment applyClubFragment=new ActiveManageMyApplyFragment();
			ft.replace(R.id.linear_invate_contact, applyClubFragment,MainActivity.TAG);
			ft.commit();


		}
	};

	private void clearSelection() {
		img_select_publish.setImageResource(R.drawable.my_active_publish_white);
		img_select_publish.setEnabled(true);
		img_select_apply.setImageResource(R.drawable.my_active_apply_white);
		img_select_apply.setEnabled(true);

	}

}
